<?php

// Global variable for table object
$creditos = NULL;

//
// Table class for creditos
//
class ccreditos extends cTable {
	var $id;
	var $fecha;
	var $usuario;
	var $financiera;
	var $tipoplan;
	var $amortizacion;
	var $cliente;
	var $tipoCredito;
	var $creditoAnterior;
	var $estado;
	var $autorizacion;
	var $gracia;
	var $tasa;
	var $activo;
	var $primerVencimiento;
	var $cuotas;
	var $diaVto;
	var $observacion;
	var $monto;
	var $sucursal;
	var $nivelMorosidad;

	//
	// Table class constructor
	//
	function __construct() {
		global $Language;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();
		$this->TableVar = 'creditos';
		$this->TableName = 'creditos';
		$this->TableType = 'TABLE';
		$this->ExportAll = TRUE;
		$this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
		$this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
		$this->ExportPageSize = "a4"; // Page size (PDF only)
		$this->DetailAdd = FALSE; // Allow detail add
		$this->DetailEdit = FALSE; // Allow detail edit
		$this->DetailView = FALSE; // Allow detail view
		$this->ShowMultipleDetails = FALSE; // Show multiple details
		$this->GridAddRowCount = 5;
		$this->AllowAddDeleteRow = ew_AllowAddDeleteRow(); // Allow add/delete row
		$this->UserIDAllowSecurity = 0; // User ID Allow
		$this->BasicSearch = new cBasicSearch($this->TableVar);

		// id
		$this->id = new cField('creditos', 'creditos', 'x_id', 'id', '`id`', '`id`', 3, -1, FALSE, '`id`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->id->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['id'] = &$this->id;

		// fecha
		$this->fecha = new cField('creditos', 'creditos', 'x_fecha', 'fecha', '`fecha`', 'DATE_FORMAT(`fecha`, \'%d/%m/%Y\')', 133, 7, FALSE, '`fecha`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fecha->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateDMY"));
		$this->fields['fecha'] = &$this->fecha;

		// usuario
		$this->usuario = new cField('creditos', 'creditos', 'x_usuario', 'usuario', '`usuario`', '`usuario`', 3, -1, FALSE, '`usuario`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->usuario->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['usuario'] = &$this->usuario;

		// financiera
		$this->financiera = new cField('creditos', 'creditos', 'x_financiera', 'financiera', '`financiera`', '`financiera`', 3, -1, FALSE, '`financiera`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->financiera->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['financiera'] = &$this->financiera;

		// tipoplan
		$this->tipoplan = new cField('creditos', 'creditos', 'x_tipoplan', 'tipoplan', '`tipoplan`', '`tipoplan`', 3, -1, FALSE, '`tipoplan`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->tipoplan->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['tipoplan'] = &$this->tipoplan;

		// amortizacion
		$this->amortizacion = new cField('creditos', 'creditos', 'x_amortizacion', 'amortizacion', '`amortizacion`', '`amortizacion`', 3, -1, FALSE, '`amortizacion`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->amortizacion->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['amortizacion'] = &$this->amortizacion;

		// cliente
		$this->cliente = new cField('creditos', 'creditos', 'x_cliente', 'cliente', '`cliente`', '`cliente`', 3, -1, FALSE, '`cliente`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->cliente->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['cliente'] = &$this->cliente;

		// tipoCredito
		$this->tipoCredito = new cField('creditos', 'creditos', 'x_tipoCredito', 'tipoCredito', '`tipoCredito`', '`tipoCredito`', 3, -1, FALSE, '`tipoCredito`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->tipoCredito->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['tipoCredito'] = &$this->tipoCredito;

		// creditoAnterior
		$this->creditoAnterior = new cField('creditos', 'creditos', 'x_creditoAnterior', 'creditoAnterior', '`creditoAnterior`', '`creditoAnterior`', 3, -1, FALSE, '`creditoAnterior`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->creditoAnterior->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['creditoAnterior'] = &$this->creditoAnterior;

		// estado
		$this->estado = new cField('creditos', 'creditos', 'x_estado', 'estado', '`estado`', '`estado`', 3, -1, FALSE, '`estado`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->estado->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['estado'] = &$this->estado;

		// autorizacion
		$this->autorizacion = new cField('creditos', 'creditos', 'x_autorizacion', 'autorizacion', '`autorizacion`', '`autorizacion`', 200, -1, FALSE, '`autorizacion`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['autorizacion'] = &$this->autorizacion;

		// gracia
		$this->gracia = new cField('creditos', 'creditos', 'x_gracia', 'gracia', '`gracia`', '`gracia`', 3, -1, FALSE, '`gracia`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->gracia->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['gracia'] = &$this->gracia;

		// tasa
		$this->tasa = new cField('creditos', 'creditos', 'x_tasa', 'tasa', '`tasa`', '`tasa`', 131, -1, FALSE, '`tasa`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->tasa->FldDefaultErrMsg = $Language->Phrase("IncorrectFloat");
		$this->fields['tasa'] = &$this->tasa;

		// activo
		$this->activo = new cField('creditos', 'creditos', 'x_activo', 'activo', '`activo`', '`activo`', 16, -1, FALSE, '`activo`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->activo->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['activo'] = &$this->activo;

		// primerVencimiento
		$this->primerVencimiento = new cField('creditos', 'creditos', 'x_primerVencimiento', 'primerVencimiento', '`primerVencimiento`', 'DATE_FORMAT(`primerVencimiento`, \'%d/%m/%Y\')', 133, 7, FALSE, '`primerVencimiento`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->primerVencimiento->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateDMY"));
		$this->fields['primerVencimiento'] = &$this->primerVencimiento;

		// cuotas
		$this->cuotas = new cField('creditos', 'creditos', 'x_cuotas', 'cuotas', '`cuotas`', '`cuotas`', 3, -1, FALSE, '`cuotas`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->cuotas->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['cuotas'] = &$this->cuotas;

		// diaVto
		$this->diaVto = new cField('creditos', 'creditos', 'x_diaVto', 'diaVto', '`diaVto`', '`diaVto`', 3, -1, FALSE, '`diaVto`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->diaVto->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['diaVto'] = &$this->diaVto;

		// observacion
		$this->observacion = new cField('creditos', 'creditos', 'x_observacion', 'observacion', '`observacion`', '`observacion`', 201, -1, FALSE, '`observacion`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->fields['observacion'] = &$this->observacion;

		// monto
		$this->monto = new cField('creditos', 'creditos', 'x_monto', 'monto', '`monto`', '`monto`', 131, -1, FALSE, '`monto`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->monto->FldDefaultErrMsg = $Language->Phrase("IncorrectFloat");
		$this->fields['monto'] = &$this->monto;

		// sucursal
		$this->sucursal = new cField('creditos', 'creditos', 'x_sucursal', 'sucursal', '`sucursal`', '`sucursal`', 3, -1, FALSE, '`sucursal`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->sucursal->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['sucursal'] = &$this->sucursal;

		// nivelMorosidad
		$this->nivelMorosidad = new cField('creditos', 'creditos', 'x_nivelMorosidad', 'nivelMorosidad', '`nivelMorosidad`', '`nivelMorosidad`', 3, -1, FALSE, '`nivelMorosidad`', FALSE, FALSE, FALSE, 'FORMATTED TEXT');
		$this->nivelMorosidad->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['nivelMorosidad'] = &$this->nivelMorosidad;
	}

	// Single column sort
	function UpdateSort(&$ofld) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sSortField = $ofld->FldExpression;
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
			$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
		} else {
			$ofld->setSort("");
		}
	}

	// Current detail table name
	function getCurrentDetailTable() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE];
	}

	function setCurrentDetailTable($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_DETAIL_TABLE] = $v;
	}

	// Get detail url
	function GetDetailUrl() {

		// Detail url
		$sDetailUrl = "";
		if ($this->getCurrentDetailTable() == "cuotascredito") {
			$sDetailUrl = $GLOBALS["cuotascredito"]->GetListUrl() . "?showmaster=" . $this->TableVar;
			$sDetailUrl .= "&creditoId=" . $this->id->CurrentValue;
		}
		if ($sDetailUrl == "") {
			$sDetailUrl = "creditoslist.php";
		}
		return $sDetailUrl;
	}

	// Table level SQL
	function SqlFrom() { // From
		return "`creditos`";
	}

	function SqlSelect() { // Select
		return "SELECT * FROM " . $this->SqlFrom();
	}

	function SqlWhere() { // Where
		$sWhere = "";
		$this->TableFilter = "";
		ew_AddFilter($sWhere, $this->TableFilter);
		return $sWhere;
	}

	function SqlGroupBy() { // Group By
		return "";
	}

	function SqlHaving() { // Having
		return "";
	}

	function SqlOrderBy() { // Order By
		return "`id` DESC";
	}

	// Check if Anonymous User is allowed
	function AllowAnonymousUser() {
		switch (@$this->PageID) {
			case "add":
			case "register":
			case "addopt":
				return FALSE;
			case "edit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return FALSE;
			case "delete":
				return FALSE;
			case "view":
				return FALSE;
			case "search":
				return FALSE;
			default:
				return FALSE;
		}
	}

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		return $sFilter;
	}

	// Check if User ID security allows view all
	function UserIDAllow($id = "") {
		$allow = EW_USER_ID_ALLOW;
		switch ($id) {
			case "add":
			case "copy":
			case "gridadd":
			case "register":
			case "addopt":
				return (($allow & 1) == 1);
			case "edit":
			case "gridedit":
			case "update":
			case "changepwd":
			case "forgotpwd":
				return (($allow & 4) == 4);
			case "delete":
				return (($allow & 2) == 2);
			case "view":
				return (($allow & 8) == 8);
			case "search":
				return (($allow & 8) == 8);
			default:
				return (($allow & 8) == 8);
		}
	}

	// Get SQL
	function GetSQL($where, $orderby) {
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$where, $orderby);
	}

	// Table SQL
	function SQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$sFilter, $sSort);
	}

	// Table SQL with List page filter
	function SelectSQL() {
		$sFilter = $this->getSessionWhere();
		ew_AddFilter($sFilter, $this->CurrentFilter);
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(), $this->SqlGroupBy(),
			$this->SqlHaving(), $this->SqlOrderBy(), $sFilter, $sSort);
	}

	// Get ORDER BY clause
	function GetOrderBy() {
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql("", "", "", "", $this->SqlOrderBy(), "", $sSort);
	}

	// Try to get record count
	function TryGetRecordCount($sSql) {
		global $conn;
		$cnt = -1;
		if ($this->TableType == 'TABLE' || $this->TableType == 'VIEW') {
			$sSql = "SELECT COUNT(*) FROM" . preg_replace('/^SELECT\s([\s\S]+)?\*\sFROM/i', "", $sSql);
			$sOrderBy = $this->GetOrderBy();
			if (substr($sSql, strlen($sOrderBy) * -1) == $sOrderBy)
				$sSql = substr($sSql, 0, strlen($sSql) - strlen($sOrderBy)); // Remove ORDER BY clause
		} else {
			$sSql = "SELECT COUNT(*) FROM (" . $sSql . ") EW_COUNT_TABLE";
		}
		if ($rs = $conn->Execute($sSql)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// Get record count based on filter (for detail record count in master table pages)
	function LoadRecordCount($sFilter) {
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $sFilter;
		$this->Recordset_Selecting($this->CurrentFilter);

		//$sSql = $this->SQL();
		$sSql = $this->GetSQL($this->CurrentFilter, "");
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $this->LoadRs($this->CurrentFilter)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Get record count (for current List page)
	function SelectRecordCount() {
		global $conn;
		$origFilter = $this->CurrentFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SelectSQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $conn->Execute($sSql)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Update Table
	var $UpdateTable = "`creditos`";

	// INSERT statement
	function InsertSQL(&$rs) {
		global $conn;
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]))
				continue;
			$names .= $this->fields[$name]->FldExpression . ",";
			$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		while (substr($names, -1) == ",")
			$names = substr($names, 0, -1);
		while (substr($values, -1) == ",")
			$values = substr($values, 0, -1);
		return "INSERT INTO " . $this->UpdateTable . " ($names) VALUES ($values)";
	}

	// Insert
	function Insert(&$rs) {
		global $conn;
		return $conn->Execute($this->InsertSQL($rs));
	}

	// UPDATE statement
	function UpdateSQL(&$rs, $where = "") {
		$sql = "UPDATE " . $this->UpdateTable . " SET ";
		foreach ($rs as $name => $value) {
			if (!isset($this->fields[$name]))
				continue;
			$sql .= $this->fields[$name]->FldExpression . "=";
			$sql .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		while (substr($sql, -1) == ",")
			$sql = substr($sql, 0, -1);
		$filter = $this->CurrentFilter;
		ew_AddFilter($filter, $where);
		if ($filter <> "")	$sql .= " WHERE " . $filter;
		return $sql;
	}

	// Update
	function Update(&$rs, $where = "", $rsold = NULL) {
		global $conn;
		return $conn->Execute($this->UpdateSQL($rs, $where));
	}

	// DELETE statement
	function DeleteSQL(&$rs, $where = "") {
		$sql = "DELETE FROM " . $this->UpdateTable . " WHERE ";
		if ($rs) {
			if (array_key_exists('id', $rs))
				ew_AddFilter($where, ew_QuotedName('id') . '=' . ew_QuotedValue($rs['id'], $this->id->FldDataType));
		}
		$filter = $this->CurrentFilter;
		ew_AddFilter($filter, $where);
		if ($filter <> "")
			$sql .= $filter;
		else
			$sql .= "0=1"; // Avoid delete
		return $sql;
	}

	// Delete
	function Delete(&$rs, $where = "") {
		global $conn;
		return $conn->Execute($this->DeleteSQL($rs, $where));
	}

	// Key filter WHERE clause
	function SqlKeyFilter() {
		return "`id` = @id@";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		if (!is_numeric($this->id->CurrentValue))
			$sKeyFilter = "0=1"; // Invalid key
		$sKeyFilter = str_replace("@id@", ew_AdjustSql($this->id->CurrentValue), $sKeyFilter); // Replace key value
		return $sKeyFilter;
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "creditoslist.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// List URL
	function GetListUrl() {
		return "creditoslist.php";
	}

	// View URL
	function GetViewUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("creditosview.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("creditosview.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Add URL
	function GetAddUrl() {
		return "creditosadd.php";
	}

	// Edit URL
	function GetEditUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("creditosedit.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("creditosedit.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Inline edit URL
	function GetInlineEditUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
	}

	// Copy URL
	function GetCopyUrl($parm = "") {
		if ($parm <> "")
			return $this->KeyUrl("creditosadd.php", $this->UrlParm($parm));
		else
			return $this->KeyUrl("creditosadd.php", $this->UrlParm(EW_TABLE_SHOW_DETAIL . "="));
	}

	// Inline copy URL
	function GetInlineCopyUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
	}

	// Delete URL
	function GetDeleteUrl() {
		return $this->KeyUrl("creditosdelete.php", $this->UrlParm());
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		if (!is_null($this->id->CurrentValue)) {
			$sUrl .= "id=" . urlencode($this->id->CurrentValue);
		} else {
			return "javascript:alert(ewLanguage.Phrase('InvalidRecord'));";
		}
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&amp;ordertype=" . $fld->ReverseSort());
			return ew_CurrentPage() . "?" . $sUrlParm;
		} else {
			return "";
		}
	}

	// Get record keys from $_POST/$_GET/$_SESSION
	function GetRecordKeys() {
		global $EW_COMPOSITE_KEY_SEPARATOR;
		$arKeys = array();
		$arKey = array();
		if (isset($_POST["key_m"])) {
			$arKeys = ew_StripSlashes($_POST["key_m"]);
			$cnt = count($arKeys);
		} elseif (isset($_GET["key_m"])) {
			$arKeys = ew_StripSlashes($_GET["key_m"]);
			$cnt = count($arKeys);
		} elseif (isset($_GET)) {
			$arKeys[] = @$_GET["id"]; // id

			//return $arKeys; // Do not return yet, so the values will also be checked by the following code
		}

		// Check keys
		$ar = array();
		foreach ($arKeys as $key) {
			if (!is_numeric($key))
				continue;
			$ar[] = $key;
		}
		return $ar;
	}

	// Get key filter
	function GetKeyFilter() {
		$arKeys = $this->GetRecordKeys();
		$sKeyFilter = "";
		foreach ($arKeys as $key) {
			if ($sKeyFilter <> "") $sKeyFilter .= " OR ";
			$this->id->CurrentValue = $key;
			$sKeyFilter .= "(" . $this->KeyFilter() . ")";
		}
		return $sKeyFilter;
	}

	// Load rows based on filter
	function &LoadRs($sFilter) {
		global $conn;

		// Set up filter (SQL WHERE clause) and get return SQL
		//$this->CurrentFilter = $sFilter;
		//$sSql = $this->SQL();

		$sSql = $this->GetSQL($sFilter, "");
		$rs = $conn->Execute($sSql);
		return $rs;
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->id->setDbValue($rs->fields('id'));
		$this->fecha->setDbValue($rs->fields('fecha'));
		$this->usuario->setDbValue($rs->fields('usuario'));
		$this->financiera->setDbValue($rs->fields('financiera'));
		$this->tipoplan->setDbValue($rs->fields('tipoplan'));
		$this->amortizacion->setDbValue($rs->fields('amortizacion'));
		$this->cliente->setDbValue($rs->fields('cliente'));
		$this->tipoCredito->setDbValue($rs->fields('tipoCredito'));
		$this->creditoAnterior->setDbValue($rs->fields('creditoAnterior'));
		$this->estado->setDbValue($rs->fields('estado'));
		$this->autorizacion->setDbValue($rs->fields('autorizacion'));
		$this->gracia->setDbValue($rs->fields('gracia'));
		$this->tasa->setDbValue($rs->fields('tasa'));
		$this->activo->setDbValue($rs->fields('activo'));
		$this->primerVencimiento->setDbValue($rs->fields('primerVencimiento'));
		$this->cuotas->setDbValue($rs->fields('cuotas'));
		$this->diaVto->setDbValue($rs->fields('diaVto'));
		$this->observacion->setDbValue($rs->fields('observacion'));
		$this->monto->setDbValue($rs->fields('monto'));
		$this->sucursal->setDbValue($rs->fields('sucursal'));
		$this->nivelMorosidad->setDbValue($rs->fields('nivelMorosidad'));
	}

	// Render list row values
	function RenderListRow() {
		global $conn, $Security, $gsLanguage;

		// Call Row Rendering event
		$this->Row_Rendering();

   // Common render codes
		// id
		// fecha
		// usuario
		// financiera
		// tipoplan
		// amortizacion
		// cliente
		// tipoCredito
		// creditoAnterior
		// estado
		// autorizacion
		// gracia
		// tasa
		// activo
		// primerVencimiento
		// cuotas
		// diaVto
		// observacion
		// monto
		// sucursal
		// nivelMorosidad
		// id

		$this->id->ViewValue = $this->id->CurrentValue;
		$this->id->ViewCustomAttributes = "";

		// fecha
		$this->fecha->ViewValue = $this->fecha->CurrentValue;
		$this->fecha->ViewValue = ew_FormatDateTime($this->fecha->ViewValue, 7);
		$this->fecha->ViewCustomAttributes = "";

		// usuario
		$this->usuario->ViewValue = $this->usuario->CurrentValue;
		$this->usuario->ViewCustomAttributes = "";

		// financiera
		if (strval($this->financiera->CurrentValue) <> "") {
			$sFilterWrk = "`id`" . ew_SearchString("=", $this->financiera->CurrentValue, EW_DATATYPE_NUMBER);
		$sSqlWrk = "SELECT `id`, `Nombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `tipocreditos`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->financiera, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->financiera->ViewValue = $rswrk->fields('DispFld');
				$rswrk->Close();
			} else {
				$this->financiera->ViewValue = $this->financiera->CurrentValue;
			}
		} else {
			$this->financiera->ViewValue = NULL;
		}
		$this->financiera->ViewCustomAttributes = "";

		// tipoplan
		if (strval($this->tipoplan->CurrentValue) <> "") {
			$sFilterWrk = "`id`" . ew_SearchString("=", $this->tipoplan->CurrentValue, EW_DATATYPE_NUMBER);
		$sSqlWrk = "SELECT `id`, `nombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `planes`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->tipoplan, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->tipoplan->ViewValue = $rswrk->fields('DispFld');
				$rswrk->Close();
			} else {
				$this->tipoplan->ViewValue = $this->tipoplan->CurrentValue;
			}
		} else {
			$this->tipoplan->ViewValue = NULL;
		}
		$this->tipoplan->ViewCustomAttributes = "";

		// amortizacion
		$this->amortizacion->ViewValue = $this->amortizacion->CurrentValue;
		$this->amortizacion->ViewCustomAttributes = "";

		// cliente
		$this->cliente->ViewValue = $this->cliente->CurrentValue;
		if (strval($this->cliente->CurrentValue) <> "") {
			$sFilterWrk = "`Dni`" . ew_SearchString("=", $this->cliente->CurrentValue, EW_DATATYPE_STRING);
		$sSqlWrk = "SELECT `Dni`, `Apellido` AS `DispFld`, `Nombre` AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `clientes`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->cliente, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->cliente->ViewValue = $rswrk->fields('DispFld');
				$this->cliente->ViewValue .= ew_ValueSeparator(1,$this->cliente) . $rswrk->fields('Disp2Fld');
				$rswrk->Close();
			} else {
				$this->cliente->ViewValue = $this->cliente->CurrentValue;
			}
		} else {
			$this->cliente->ViewValue = NULL;
		}
		$this->cliente->ViewCustomAttributes = "";

		// tipoCredito
		if (strval($this->tipoCredito->CurrentValue) <> "") {
			switch ($this->tipoCredito->CurrentValue) {
				case $this->tipoCredito->FldTagValue(1):
					$this->tipoCredito->ViewValue = $this->tipoCredito->FldTagCaption(1) <> "" ? $this->tipoCredito->FldTagCaption(1) : $this->tipoCredito->CurrentValue;
					break;
				case $this->tipoCredito->FldTagValue(2):
					$this->tipoCredito->ViewValue = $this->tipoCredito->FldTagCaption(2) <> "" ? $this->tipoCredito->FldTagCaption(2) : $this->tipoCredito->CurrentValue;
					break;
				default:
					$this->tipoCredito->ViewValue = $this->tipoCredito->CurrentValue;
			}
		} else {
			$this->tipoCredito->ViewValue = NULL;
		}
		$this->tipoCredito->ViewCustomAttributes = "";

		// creditoAnterior
		$this->creditoAnterior->ViewValue = $this->creditoAnterior->CurrentValue;
		$this->creditoAnterior->ViewCustomAttributes = "";

		// estado
		if (strval($this->estado->CurrentValue) <> "") {
			switch ($this->estado->CurrentValue) {
				case $this->estado->FldTagValue(1):
					$this->estado->ViewValue = $this->estado->FldTagCaption(1) <> "" ? $this->estado->FldTagCaption(1) : $this->estado->CurrentValue;
					break;
				case $this->estado->FldTagValue(2):
					$this->estado->ViewValue = $this->estado->FldTagCaption(2) <> "" ? $this->estado->FldTagCaption(2) : $this->estado->CurrentValue;
					break;
				case $this->estado->FldTagValue(3):
					$this->estado->ViewValue = $this->estado->FldTagCaption(3) <> "" ? $this->estado->FldTagCaption(3) : $this->estado->CurrentValue;
					break;
				default:
					$this->estado->ViewValue = $this->estado->CurrentValue;
			}
		} else {
			$this->estado->ViewValue = NULL;
		}
		$this->estado->ViewCustomAttributes = "";

		// autorizacion
		$this->autorizacion->ViewValue = $this->autorizacion->CurrentValue;
		$this->autorizacion->ViewCustomAttributes = "";

		// gracia
		$this->gracia->ViewValue = $this->gracia->CurrentValue;
		$this->gracia->ViewCustomAttributes = "";

		// tasa
		$this->tasa->ViewValue = $this->tasa->CurrentValue;
		$this->tasa->ViewCustomAttributes = "";

		// activo
		$this->activo->ViewValue = $this->activo->CurrentValue;
		$this->activo->ViewCustomAttributes = "";

		// primerVencimiento
		$this->primerVencimiento->ViewValue = $this->primerVencimiento->CurrentValue;
		$this->primerVencimiento->ViewValue = ew_FormatDateTime($this->primerVencimiento->ViewValue, 7);
		$this->primerVencimiento->ViewCustomAttributes = "";

		// cuotas
		$this->cuotas->ViewValue = $this->cuotas->CurrentValue;
		$this->cuotas->ViewCustomAttributes = "";

		// diaVto
		$this->diaVto->ViewValue = $this->diaVto->CurrentValue;
		$this->diaVto->ViewCustomAttributes = "";

		// observacion
		$this->observacion->ViewValue = $this->observacion->CurrentValue;
		$this->observacion->ViewCustomAttributes = "";

		// monto
		$this->monto->ViewValue = $this->monto->CurrentValue;
		$this->monto->ViewCustomAttributes = "";

		// sucursal
		if (strval($this->sucursal->CurrentValue) <> "") {
			$sFilterWrk = "`id`" . ew_SearchString("=", $this->sucursal->CurrentValue, EW_DATATYPE_NUMBER);
		$sSqlWrk = "SELECT `id`, `Nombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			ew_AddFilter($sWhereWrk, $sFilterWrk);
		}

		// Call Lookup selecting
		$this->Lookup_Selecting($this->sucursal, $sWhereWrk);
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->sucursal->ViewValue = $rswrk->fields('DispFld');
				$rswrk->Close();
			} else {
				$this->sucursal->ViewValue = $this->sucursal->CurrentValue;
			}
		} else {
			$this->sucursal->ViewValue = NULL;
		}
		$this->sucursal->ViewCustomAttributes = "";

		// nivelMorosidad
		$this->nivelMorosidad->ViewValue = $this->nivelMorosidad->CurrentValue;
		$this->nivelMorosidad->ViewCustomAttributes = "";

		// id
		$this->id->LinkCustomAttributes = "";
		$this->id->HrefValue = "";
		$this->id->TooltipValue = "";

		// fecha
		$this->fecha->LinkCustomAttributes = "";
		$this->fecha->HrefValue = "";
		$this->fecha->TooltipValue = "";

		// usuario
		$this->usuario->LinkCustomAttributes = "";
		$this->usuario->HrefValue = "";
		$this->usuario->TooltipValue = "";

		// financiera
		$this->financiera->LinkCustomAttributes = "";
		$this->financiera->HrefValue = "";
		$this->financiera->TooltipValue = "";

		// tipoplan
		$this->tipoplan->LinkCustomAttributes = "";
		$this->tipoplan->HrefValue = "";
		$this->tipoplan->TooltipValue = "";

		// amortizacion
		$this->amortizacion->LinkCustomAttributes = "";
		$this->amortizacion->HrefValue = "";
		$this->amortizacion->TooltipValue = "";

		// cliente
		$this->cliente->LinkCustomAttributes = "";
		$this->cliente->HrefValue = "";
		$this->cliente->TooltipValue = "";

		// tipoCredito
		$this->tipoCredito->LinkCustomAttributes = "";
		$this->tipoCredito->HrefValue = "";
		$this->tipoCredito->TooltipValue = "";

		// creditoAnterior
		$this->creditoAnterior->LinkCustomAttributes = "";
		$this->creditoAnterior->HrefValue = "";
		$this->creditoAnterior->TooltipValue = "";

		// estado
		$this->estado->LinkCustomAttributes = "";
		$this->estado->HrefValue = "";
		$this->estado->TooltipValue = "";

		// autorizacion
		$this->autorizacion->LinkCustomAttributes = "";
		$this->autorizacion->HrefValue = "";
		$this->autorizacion->TooltipValue = "";

		// gracia
		$this->gracia->LinkCustomAttributes = "";
		$this->gracia->HrefValue = "";
		$this->gracia->TooltipValue = "";

		// tasa
		$this->tasa->LinkCustomAttributes = "";
		$this->tasa->HrefValue = "";
		$this->tasa->TooltipValue = "";

		// activo
		$this->activo->LinkCustomAttributes = "";
		$this->activo->HrefValue = "";
		$this->activo->TooltipValue = "";

		// primerVencimiento
		$this->primerVencimiento->LinkCustomAttributes = "";
		$this->primerVencimiento->HrefValue = "";
		$this->primerVencimiento->TooltipValue = "";

		// cuotas
		$this->cuotas->LinkCustomAttributes = "";
		$this->cuotas->HrefValue = "";
		$this->cuotas->TooltipValue = "";

		// diaVto
		$this->diaVto->LinkCustomAttributes = "";
		$this->diaVto->HrefValue = "";
		$this->diaVto->TooltipValue = "";

		// observacion
		$this->observacion->LinkCustomAttributes = "";
		$this->observacion->HrefValue = "";
		$this->observacion->TooltipValue = "";

		// monto
		$this->monto->LinkCustomAttributes = "";
		$this->monto->HrefValue = "";
		$this->monto->TooltipValue = "";

		// sucursal
		$this->sucursal->LinkCustomAttributes = "";
		$this->sucursal->HrefValue = "";
		$this->sucursal->TooltipValue = "";

		// nivelMorosidad
		$this->nivelMorosidad->LinkCustomAttributes = "";
		$this->nivelMorosidad->HrefValue = "";
		$this->nivelMorosidad->TooltipValue = "";

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
	}

	// Export data in HTML/CSV/Word/Excel/Email/PDF format
	function ExportDocument(&$Doc, &$Recordset, $StartRec, $StopRec, $ExportPageType = "") {
		if (!$Recordset || !$Doc)
			return;

		// Write header
		$Doc->ExportTableHeader();
		if ($Doc->Horizontal) { // Horizontal format, write header
			$Doc->BeginExportRow();
			if ($ExportPageType == "view") {
				if ($this->id->Exportable) $Doc->ExportCaption($this->id);
				if ($this->fecha->Exportable) $Doc->ExportCaption($this->fecha);
				if ($this->usuario->Exportable) $Doc->ExportCaption($this->usuario);
				if ($this->financiera->Exportable) $Doc->ExportCaption($this->financiera);
				if ($this->tipoplan->Exportable) $Doc->ExportCaption($this->tipoplan);
				if ($this->amortizacion->Exportable) $Doc->ExportCaption($this->amortizacion);
				if ($this->cliente->Exportable) $Doc->ExportCaption($this->cliente);
				if ($this->tipoCredito->Exportable) $Doc->ExportCaption($this->tipoCredito);
				if ($this->creditoAnterior->Exportable) $Doc->ExportCaption($this->creditoAnterior);
				if ($this->estado->Exportable) $Doc->ExportCaption($this->estado);
				if ($this->autorizacion->Exportable) $Doc->ExportCaption($this->autorizacion);
				if ($this->gracia->Exportable) $Doc->ExportCaption($this->gracia);
				if ($this->tasa->Exportable) $Doc->ExportCaption($this->tasa);
				if ($this->activo->Exportable) $Doc->ExportCaption($this->activo);
				if ($this->primerVencimiento->Exportable) $Doc->ExportCaption($this->primerVencimiento);
				if ($this->cuotas->Exportable) $Doc->ExportCaption($this->cuotas);
				if ($this->diaVto->Exportable) $Doc->ExportCaption($this->diaVto);
				if ($this->observacion->Exportable) $Doc->ExportCaption($this->observacion);
				if ($this->monto->Exportable) $Doc->ExportCaption($this->monto);
				if ($this->sucursal->Exportable) $Doc->ExportCaption($this->sucursal);
				if ($this->nivelMorosidad->Exportable) $Doc->ExportCaption($this->nivelMorosidad);
			} else {
				if ($this->id->Exportable) $Doc->ExportCaption($this->id);
				if ($this->fecha->Exportable) $Doc->ExportCaption($this->fecha);
				if ($this->usuario->Exportable) $Doc->ExportCaption($this->usuario);
				if ($this->financiera->Exportable) $Doc->ExportCaption($this->financiera);
				if ($this->tipoplan->Exportable) $Doc->ExportCaption($this->tipoplan);
				if ($this->amortizacion->Exportable) $Doc->ExportCaption($this->amortizacion);
				if ($this->cliente->Exportable) $Doc->ExportCaption($this->cliente);
				if ($this->tipoCredito->Exportable) $Doc->ExportCaption($this->tipoCredito);
				if ($this->creditoAnterior->Exportable) $Doc->ExportCaption($this->creditoAnterior);
				if ($this->estado->Exportable) $Doc->ExportCaption($this->estado);
				if ($this->autorizacion->Exportable) $Doc->ExportCaption($this->autorizacion);
				if ($this->gracia->Exportable) $Doc->ExportCaption($this->gracia);
				if ($this->tasa->Exportable) $Doc->ExportCaption($this->tasa);
				if ($this->activo->Exportable) $Doc->ExportCaption($this->activo);
				if ($this->primerVencimiento->Exportable) $Doc->ExportCaption($this->primerVencimiento);
				if ($this->cuotas->Exportable) $Doc->ExportCaption($this->cuotas);
				if ($this->diaVto->Exportable) $Doc->ExportCaption($this->diaVto);
				if ($this->monto->Exportable) $Doc->ExportCaption($this->monto);
				if ($this->sucursal->Exportable) $Doc->ExportCaption($this->sucursal);
				if ($this->nivelMorosidad->Exportable) $Doc->ExportCaption($this->nivelMorosidad);
			}
			$Doc->EndExportRow();
		}

		// Move to first record
		$RecCnt = $StartRec - 1;
		if (!$Recordset->EOF) {
			$Recordset->MoveFirst();
			if ($StartRec > 1)
				$Recordset->Move($StartRec - 1);
		}
		while (!$Recordset->EOF && $RecCnt < $StopRec) {
			$RecCnt++;
			if (intval($RecCnt) >= intval($StartRec)) {
				$RowCnt = intval($RecCnt) - intval($StartRec) + 1;

				// Page break
				if ($this->ExportPageBreakCount > 0) {
					if ($RowCnt > 1 && ($RowCnt - 1) % $this->ExportPageBreakCount == 0)
						$Doc->ExportPageBreak();
				}
				$this->LoadListRowValues($Recordset);

				// Render row
				$this->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->ResetAttrs();
				$this->RenderListRow();
				$Doc->BeginExportRow($RowCnt); // Allow CSS styles if enabled
				if ($ExportPageType == "view") {
					if ($this->id->Exportable) $Doc->ExportField($this->id);
					if ($this->fecha->Exportable) $Doc->ExportField($this->fecha);
					if ($this->usuario->Exportable) $Doc->ExportField($this->usuario);
					if ($this->financiera->Exportable) $Doc->ExportField($this->financiera);
					if ($this->tipoplan->Exportable) $Doc->ExportField($this->tipoplan);
					if ($this->amortizacion->Exportable) $Doc->ExportField($this->amortizacion);
					if ($this->cliente->Exportable) $Doc->ExportField($this->cliente);
					if ($this->tipoCredito->Exportable) $Doc->ExportField($this->tipoCredito);
					if ($this->creditoAnterior->Exportable) $Doc->ExportField($this->creditoAnterior);
					if ($this->estado->Exportable) $Doc->ExportField($this->estado);
					if ($this->autorizacion->Exportable) $Doc->ExportField($this->autorizacion);
					if ($this->gracia->Exportable) $Doc->ExportField($this->gracia);
					if ($this->tasa->Exportable) $Doc->ExportField($this->tasa);
					if ($this->activo->Exportable) $Doc->ExportField($this->activo);
					if ($this->primerVencimiento->Exportable) $Doc->ExportField($this->primerVencimiento);
					if ($this->cuotas->Exportable) $Doc->ExportField($this->cuotas);
					if ($this->diaVto->Exportable) $Doc->ExportField($this->diaVto);
					if ($this->observacion->Exportable) $Doc->ExportField($this->observacion);
					if ($this->monto->Exportable) $Doc->ExportField($this->monto);
					if ($this->sucursal->Exportable) $Doc->ExportField($this->sucursal);
					if ($this->nivelMorosidad->Exportable) $Doc->ExportField($this->nivelMorosidad);
				} else {
					if ($this->id->Exportable) $Doc->ExportField($this->id);
					if ($this->fecha->Exportable) $Doc->ExportField($this->fecha);
					if ($this->usuario->Exportable) $Doc->ExportField($this->usuario);
					if ($this->financiera->Exportable) $Doc->ExportField($this->financiera);
					if ($this->tipoplan->Exportable) $Doc->ExportField($this->tipoplan);
					if ($this->amortizacion->Exportable) $Doc->ExportField($this->amortizacion);
					if ($this->cliente->Exportable) $Doc->ExportField($this->cliente);
					if ($this->tipoCredito->Exportable) $Doc->ExportField($this->tipoCredito);
					if ($this->creditoAnterior->Exportable) $Doc->ExportField($this->creditoAnterior);
					if ($this->estado->Exportable) $Doc->ExportField($this->estado);
					if ($this->autorizacion->Exportable) $Doc->ExportField($this->autorizacion);
					if ($this->gracia->Exportable) $Doc->ExportField($this->gracia);
					if ($this->tasa->Exportable) $Doc->ExportField($this->tasa);
					if ($this->activo->Exportable) $Doc->ExportField($this->activo);
					if ($this->primerVencimiento->Exportable) $Doc->ExportField($this->primerVencimiento);
					if ($this->cuotas->Exportable) $Doc->ExportField($this->cuotas);
					if ($this->diaVto->Exportable) $Doc->ExportField($this->diaVto);
					if ($this->monto->Exportable) $Doc->ExportField($this->monto);
					if ($this->sucursal->Exportable) $Doc->ExportField($this->sucursal);
					if ($this->nivelMorosidad->Exportable) $Doc->ExportField($this->nivelMorosidad);
				}
				$Doc->EndExportRow();
			}
			$Recordset->MoveNext();
		}
		$Doc->ExportTableFooter();
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here	
	}

	// Recordset Selected event
	function Recordset_Selected(&$rs) {

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

		// Example:
		//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here	
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here	
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Inserting event
	function Row_Inserting($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted($rsold, &$rsnew) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating($rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated($rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict($rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}

	// Lookup Selecting event
	function Lookup_Selecting($fld, &$filter) {

		// Enter your code here
	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

	// Row Rendered event
	function Row_Rendered() {

		// To view properties of field class, use:
		//var_dump($this-><FieldName>); 

	}

	// User ID Filtering event
	function UserID_Filtering(&$filter) {

		// Enter your code here
	}
}
?>
